package com.cskaoyan.service;

import com.cskaoyan.bean.MarketLog;
import com.cskaoyan.bean.MarketLogExample;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.mapper.MarketLogMapper;
import com.cskaoyan.util.MyBatisUtil;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class AdminLogServiceImpl implements AdminLogService {
    @Override
    public BaseRespVo list(Integer page, Integer limit, String sort, String oder, String name) {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        MarketLogMapper mapper = sqlSession.getMapper(MarketLogMapper.class);
        PageHelper.startPage(page,limit);
        MarketLogExample marketLogExample = new MarketLogExample();
        if (name!=null&&name!=""){
            marketLogExample.createCriteria().andAdminEqualTo(name);
        }
        List<MarketLog> marketLogs = mapper.selectByExample(marketLogExample);
        CommonData data = CommonData.data(marketLogs);


        return BaseRespVo.ok(data);
    }
}
